<template>
	<el-config-provider :locale="locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
		<router-view></router-view>
	</el-config-provider>
</template>

<script>
	import colorTool from '@/utils/color'

	export default {
		name: 'App',
		data() {
			return {
				config: {
					size: "default",
					zIndex: 2000,
					button: {
						autoInsertSpace: false
					}
				}
			}
		},
		computed: {
			locale(){
				return this.$i18n.messages[this.$i18n.locale].el
			},
		},
		created() {
			//设置主题颜色
			const app_color = this.$CONFIG.COLOR || this.$TOOL.data.get('APP_COLOR')
			if(app_color){
				document.documentElement.style.setProperty('--el-color-primary', app_color);
				for (let i = 1; i <= 9; i++) {
					document.documentElement.style.setProperty(`--el-color-primary-light-${i}`, colorTool.lighten(app_color,i/10));
				}
				for (let i = 1; i <= 9; i++) {
					document.documentElement.style.setProperty(`--el-color-primary-dark-${i}`, colorTool.darken(app_color,i/10));
				}
			}
            //在vue3中使用element-plus页面重置报ResizeObserver loop completed with undelivered notifications.
            const debounce = (fn, delay) => {
                let timer = null;
                return function () {
                let context = this;
                let args = arguments;
                clearTimeout(timer);
                timer = setTimeout(function () {
                    fn.apply(context, args);
                }, delay);
                }
            }
            const _ResizeObserver = window.ResizeObserver;
            window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
                constructor(callback) {
                callback = debounce(callback, 16);
                super(callback);
                }
            }
		}
	}
</script>

<style lang="scss">
@import '@/style/style.scss';
.el-tabs__item,.el-form-item--default .el-form-item__label{
    user-select: none;
}
.shopInfo{
    display: flex;
    align-items: center;
    justify-content: flex-start;
    .right{
        margin-left: 5px;
        text-align: start;
    }
    .img{
        width: 100px;
        height: 100%;
        margin-right: 5px;
    }
}
.day{
    display: flex;
    justify-content: center;
}
#hiwprint_iframe{
    display: none;
}
.printMain{
    padding: 15px 30px 0;
}
</style>
